package com.demo.controller;


import com.demo.dto.CommentReplyFormDTO;
import com.demo.dto.Result;
import com.demo.entity.CommentReply;
import com.demo.query.CommentReplyListQuery;
import com.demo.service.CommentReplyService;
import com.demo.utils.SystemConstants;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.web.bind.annotation.*;

import javax.annotation.Resource;
import java.util.List;

/**
 * <p>
 *  前端控制器
 * </p>
 *
 * @author Zeng
 * @since 2022-03-23
 */
@Api(tags = "评论下对话")
@RestController
@RequestMapping("/comment-reply")
public class CommentReplyController {
    @Resource
    CommentReplyService commentReplyService;

    @ApiOperation("新建对话")
    @PostMapping("/")
    Result<CommentReply> postCommentReply(@RequestBody CommentReplyFormDTO replyFormDTO) {
        return commentReplyService.postCommentReply(replyFormDTO);
    }

    @ApiOperation("删除对话")
    @DeleteMapping("/{cm_reply_id}")
    Result<CommentReply> deleteCommentReply(@PathVariable("cm_reply_id") Integer cmReplyId) {
        return commentReplyService.deleteCommentReply(cmReplyId);
    }

    @ApiOperation("获取某评论下的所有对话")
    @GetMapping("/common/byCommentId")
    Result<List<CommentReply>> getReplyListByCommentId(
            @RequestParam("comment_id") Integer commentId,
            @RequestParam(value = "current", defaultValue = "1") Integer current) {
        return commentReplyService.getReplyListByCommentId(commentId, current);
    }
}

